package com.wendal.java.happydog.bean;

import java.util.Set;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;


public class UserBean extends AbstractBean{

	
	protected String head_url;
	protected String id;
	protected String foods;
	protected String loveLevel;
	protected String bones;
	protected String name;
	protected String loves;
	
	protected String petid;
	protected PetBean myPets [];
	
	public UserBean(JSONObject jsonObject) {
		super(jsonObject);
//		initBean();
		if(jsonObject.has("myPets")){
			handleMyPets(jsonObject.getJSONArray("myPets"));
		}
	}
	
	@Override
	protected Set<String> getIgnoreField() {
		Set<String> ignoreField = super.getIgnoreField();
		ignoreField.add("myPets");
		return ignoreField;
	}
	
	private void handleMyPets(JSONArray myPetsObject){
		myPets = new PetBean[myPetsObject.size()];
		for (int i = 0; i < myPetsObject.size(); i++) {
			JSONObject object = myPetsObject.getJSONObject(i);
			myPets[i] = new PetBean(object);
		}
	}
}
